/*
 * @Title: 个人中心
 * @port: 卫志浩
 * @Author: 徐兵
 * @Date:   2018-10-08
 * @Last Modified by:   Administrator
 * @Last Modified time: 2018-10-24 10:52:19
 */
var app = {}
var module = {
  init: function () {
    app = new Vue({
      el: '#app',
      data: {
        versions: versions,
        activeKey: 0,
        userInfoData: "",
        icon: {
          normal: '../img/index/shouhui.png',
          active: '../img/index/shouhong.png',
          normal1: '../img/index/gouhui.png',
          active1: '../img/index/gouhong.png',
          active2: '../img/index/myhong.png',
          normal2: '../img/index/myhui.png',
          active3: '../img/index/pthong.png',
          normal3: '../img/index/pthui.png',
          active4:"../img/index/votegoods.png",
            normal4:"../img/index/votegoodsgray.png",
        },
        active: 4,
        num: "",//我的票选数量
        UserStatus:"",//抽奖状态
      },
      methods: {
        onClick: function (key) {
          this.activeKey = key;
        },
        init: function () {
          app.userInfo() //获取用户信息
          // app.FXPTcountUnreadNum()
          app.FXPTUserStatus()   
        
        },
        userInfo: function () { //获取用户信息
          ajaxTemplate(addressUrl + SERVICE.center, function (data) {
            if (data.tag == 0) {
              app.userInfoData = data.data.result
            } else {
              app.$toast(data.errMsg);
              app.userInfoData.waitPayOrder = 0;
              app.userInfoData.waitDeliverOrder = 0;
              app.userInfoData.waitGetOrder = 0;
            };
          }, {
            userId: userId,
          });
        },
        FXPTcountUnreadNum: function () { //我的票选数量
          if (!!access_token) {
            ajaxTemplate(addressTest + SERVICE.FXPTcountNotReadMsg, function (data) {
              if (data.tag == 0) {
                app.num = data.data.result
              } else {
                app.$toast(data.errMsg)
              };
            }, {
              userId: userId,
            });
          } else {
            jumpLogin()
          }
        },
        FXPTUserStatus: function () { //查询用户是否有抽奖资格-JS
          if (!!access_token) {
            ajaxTemplate(addressTest + SERVICE.FXPTqueryUserStatus, function (data) {
              if (data.tag == 0) {
                app.UserStatus = data.data.result
              } else {
                app.$toast(data.errMsg)
              };
            }, {
              userId: userId,
            });
          } else {
            jumpLogin()
          }
        },
        goApp: function () {
          app.$dialog.confirm({
            title: '提示',
            message: '请下载姿美汇APP进行申请退款'
          }).then(() => {
            // on confirm
            downAppFun();
          }).catch(() => {
            // on cancel
          });
        },
        logGut: function () { //退出登录
          this.$dialog.confirm({
            message: '确认退出登录吗？'
          }).then(() => { //确认
            jumpLogin();
          }).catch(() => { //取消
            console.log("取消")
          });
        }
      }

    });
    app.init();
  },
}
module.init();